package lcspm;

import lcspm.commands.CommandDelWarp;
import lcspm.commands.CommandSetWarp;
import lcspm.commands.CommandWarp;
import lcspm.lib.ConfigHandler;
import lcspm.lib.LogHelper;
import lcspm.lib.SoundHandler;
import lcspm.proxies.CommonProxy;
import net.minecraft.command.ServerCommandManager;
import net.minecraft.server.MinecraftServer;
import net.minecraftforge.common.MinecraftForge;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.SidedProxy;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.event.FMLServerStartingEvent;
import cpw.mods.fml.common.network.NetworkMod;

@Mod(modid="LCSPM", name="Warp for Single Player", version="1.0.2")
@NetworkMod(channels={"LCSPM"}, clientSideRequired=true, serverSideRequired=true)
public class Main
{

  @SidedProxy(clientSide="lcspm.proxies.ClientProxy", serverSide="lcspm.proxies.CommonProxy")
  public static CommonProxy proxy;

  @Mod.EventHandler
  public static void preInit(FMLPreInitializationEvent event)
  {
	  
	MinecraftForge.EVENT_BUS.register(new SoundHandler());
    proxy.initRenderers();
    proxy.initSounds();

    LogHelper.init();
    ConfigHandler.init(event.getSuggestedConfigurationFile());
  }

  @Mod.EventHandler
  public static void init(FMLInitializationEvent event)
  {
  }

  @Mod.EventHandler
  public static void postInit(FMLPostInitializationEvent event)
  {
  }

  @Mod.EventHandler
  public void serverStart(FMLServerStartingEvent event)
  {
    if ((MinecraftServer.getServer().getCommandManager() instanceof ServerCommandManager)) {
      ((ServerCommandManager)MinecraftServer.getServer().getCommandManager()).registerCommand(new CommandWarp());
      ((ServerCommandManager)MinecraftServer.getServer().getCommandManager()).registerCommand(new CommandSetWarp());
      ((ServerCommandManager)MinecraftServer.getServer().getCommandManager()).registerCommand(new CommandDelWarp());
      //((ServerCommandManager)MinecraftServer.getServer().getCommandManager()).registerCommand(new CommandBack());
    }
  }
}